package ws.jdbc.concurrent.driver.sqlserver.tds.datastreamtypes;

/**
 * Variable-length Data Stream.
 *
 * <p>
 * <a href=http://msdn.microsoft.com/en-us/library/dd340614>Reference</a>
 * </p>
 *
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
public abstract class VariableLengthDataStream {

  /** Data length. */
  protected Object length;
  /** Stream data. */
  protected byte[] data;

  /**
   * Create a new instance.
   *
   * @param length length value of the Variable-length Data Stream.
   * @param data actual data of the Variable-length Data Stream.
   */
  public VariableLengthDataStream(Object length, byte[] data) {
    this.length = length;
    this.data = data;
  }

  /**
   * Get the length of the Variable-length Data Stream.
   *
   * @return length value.
   */
  public abstract Object getLength();

  /**
   * Get the data from the stream.
   *
   * @return data stream.
   */
  public abstract Object getData();

  /**
   * Get an array representation of the Variable-length Data Stream.
   *
   * On the first positions of the array is the length, in little-endian byte
   * order. Then comes the actual data.
   *
   * @return
   */
  public abstract byte[] getBytes();

  /**
   * Get the number of bytes of data.
   *
   * @return number of bytes of data.
   */
  public abstract int size();
}
